package controllers

import (
	"encoding/json"
	"gif_project/db"
	"gif_project/models"
	"gif_project/utils"
	"github.com/astaxie/beego"
	_ "github.com/astaxie/beego/orm"
)

type ArticleDetailController struct {
	beego.Controller
}

// @Title api_getArticleDetail
// @Description 获取单帖数据
// @Param	body	body	models.ArticleDetailReq	true	"body for ArticleDetailReq content"
// @Success 200 {object} models.BaseResp
// @Failure 500 {object} models.BaseResp
// @router /api_getArticleDetail [post]
func (articleDetailController *ArticleDetailController) GetArticleDetail() {
	var articleDetailReq models.ArticleDetailReq
	err := json.Unmarshal(articleDetailController.Ctx.Input.RequestBody, &articleDetailReq)
	utils.CheckErr(err)
	page, err := db.GetArticleDetailWithPage(articleDetailReq.PageNo, articleDetailReq.PageSize, articleDetailReq.ArticleId)
	utils.ResBaseJson(err, page, &articleDetailController.Controller)
}
